import { defineConfig } from 'vite';
import { viteMockServe } from "vite-plugin-mock";
import type { UserConfig, ConfigEnv } from 'vite';
import { fileURLToPath } from 'url';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { resolve } from 'path'

export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
  return {
    plugins: [
      vue(),
      vueJsx(),
      viteMockServe({
        mockPath: 'mock',
        localEnabled: true,
        prodEnabled: false,
        injectCode: false,
        logger: true,
        supportTs: true,
        watchFiles: true,
        ignore: /^_/,
        injectFile: false
      })
    ],
    server: {
      host: true,
      port: 3000,
      cors: true
    },
    resolve: {
      alias: {
        '@': resolve(__dirname, 'src')
      }
    }
  }
})